<?php 
namespace app\common\model;
class Dynamic extends Common{
	protected $insert = ['addtime'=>SYS_TIME];
	public function get_lists($data, $userid){
		$pk = $this->getPk();
		// $list = $this->where($where)->limit($offset,$limit)->order($pk,"desc")->select();
		$list = $this->order($pk,"desc")->select();
		$lists = [];
		foreach ($list as $v) {
			$v['iszans'] = db("Zans")->where('userid',$userid)->where('contentid', $v['id'])->where('typeid', 1)->count();
			$v['avatar'] = get_avatar($v['send_uid']);
			$v['nickname'] = get_nickname($v['send_uid']);
			$v['addtime'] = $v['addtime'] * 1000;
			$lists[] = $v;
		}
        return $lists;
	}
	public function add_zans($id){
		$this->where('id', $id)->setInc('zans');
		return $this->where('id', $id)->value('zans');
	}
	public function add_msg($userid,$content){
		$data = [
			'send_uid' => $userid,
			'content' => $content,
			'addtime' => SYS_TIME,
		];
		return $this->insert($data);
	}
}